export default {
  state: {
    productDetail: {},
    productDesc: ""
  },

  mutations: {
    SET_PRODUCT: (state, { product, description }) => {
      state.productDetail = product
      state.productDesc = description
      console.log(state.productDesc)
    }
  },

  actions: {
    FETCH_PRODUCT_DETAIL: ({ dispatch, commit }, { id }) => {
      return dispatch('FETCH_ENDPOINT_DATA', {
        endpoint: "products/" + id
      })
      .then(({ product, description}) => {
        commit('SET_PRODUCT', { product, description })
      })
    }
  }
}